<?php
########################################################
# DMS Donations Management System v1.0                 #
# created by:  Isaac Sabas                             #
#			   Nikko Reyes							   #
#			   Miko Tiamwatt						   #
#                                                      #
# De La Salle Philippines                              #
# All Rights Reserved DLSP Copyright 2009              #
########################################################

define('ACCESS', true);	

session_start();	

# session check #
	if (!isset($_SESSION['agentId']) && $_SESSION['agentId'] == '') {
		die ('SESSION EXPIRED OR NO SESSION. RE-LOGIN.');
	}
		
# set error checking levels #			
	# enable these lines when site is to be deployed #	
	ini_set('error_reporting', E_ALL);
    ini_set('display_errors', 'On');
    //ini_set('log_errors', 'On');
    //ini_set('error_log', '/usr/local/apache/logs/error_log');
	
# include some needed files #
	# include some needed files #
	$absRoot = '../../';
	include($absRoot . 'lib/XAJAX/xajax_core/xajax.inc.php');	
	include($absRoot . 'src/AgentHandle.php');
	include($absRoot . 'src/ClientHandle.php');
	include($absRoot . 'src/DonationHandle.php');
	include($absRoot . 'src/TransactionHandle.php');
	include($absRoot . 'src/DBHandle.php');
	include($absRoot . 'datepicker/class.datepicker.php');
		
# instantiate predifined classes #
	$dbConnection = new DBHandle();													
	$xajax = new xajax();
	$dp = new datepicker($absRoot);

# XAJAX functions  #
	# register the function in xajax 		
		$xajax->registerFunction("submitDonation");
		$xajax->registerFunction("cancelDonation");
		$xajax->registerFunction("completeDonation");
		$xajax->registerFunction("updateNotes");
	
	# xajax function code 
		function updateNotes ($values) {
			$response = new xajaxResponse();
			$agentId = isset($_SESSION['agentId']) ? $_SESSION['agentId'] : '0';
			$donationId = isset($_GET['donation_id']) ? $_GET['donation_id'] : '0';
			$response->assign('donationStatusMessage', 'innerHTML', '');
			$today = date('Y-m-d | g:i A', time());
			
			if ($agentId != 0 && $donationId != 0) {
				# 1. check if the notes is empty or not
				# 2. append to the current notes
				if ($values['notesInput'] == '') {
					$response->assign('donationStatusMessage', 'innerHTML', 'Blank text. Not Updating.');
				}
				else {
					# update and append
					$donationItem = DonationHandle::getDonationItem('donation_notes', $donationId);
					$prevNotes = $donationItem['donation_notes'];
					$notes = "$prevNotes\n---\n@ $today\n" . $values['notesInput'];
					$result = DonationHandle::updateDonationItem('donation_notes', $notes, $donationId);
					
					if ($result) {
						$response->call("parent.window.frames.ticketdonation_window_$donationId.location.reload()"); // refresh the donation frame so the note will be seen				
					}
					else {
						$response->assign('donationStatusMessage', 'innerHTML', 'Update Error.');
					}	
				}
			}
			else {
				$response->assign('donationStatusMessage', 'innerHTML', 'No Donation ID and Agent ID. ERROR.');
				$response->assign('donationStatusMessage', 'style.color', 'red');
			}
			
			return $response;
		}
		
		function cancelDonation () {
			$response = new xajaxResponse();
			$agentId = isset($_SESSION['agentId']) ? $_SESSION['agentId'] : '0';
			$donationId = isset($_GET['donation_id']) ? $_GET['donation_id'] : '0';
			
			if ($agentId != 0 && $donationId != 0) {
				$result = DonationHandle::cancelDonationTicket($donationId);
				if ($result) {
					$response->assign('donationStatusMessage', 'innerHTML', 'Donation marked for discontinuation.');
					$response->assign('donationStatusMessage', 'style.color', 'green');
					$response->assign('cancelDonationButton', 'style.display', 'none');
					$response->assign('completeDonationButton', 'style.display', 'none');
					$response->assign('newTransactionButton', 'style.display', 'none');
					$response->assign('editButton', 'disabled', 'disabled');
					$response->assign('notesSubmit', 'disabled', 'disabled');
					$response->assign('notesInput', 'disabled', 'disabled');
				}
				else {
					$response->assign('donationStatusMessage', 'innerHTML', 'Error in updating donation ticket.');
					$response->assign('donationStatusMessage', 'style.color', 'red');
				}
			}
			else {
				$response->assign('donationStatusMessage', 'innerHTML', 'No Donation ID and Agent ID. ERROR.');
				$response->assign('donationStatusMessage', 'style.color', 'red');
			}
			$response->call("parent.YAHOO.dms.cancel_donation_dialog[$donationId].hide()");
			return$response;
		}
		
		function completeDonation () {
			$response = new xajaxResponse();
			$agentId = isset($_SESSION['agentId']) ? $_SESSION['agentId'] : '0';
			$donationId = isset($_GET['donation_id']) ? $_GET['donation_id'] : '0';
			
			if ($agentId != 0 && $donationId != 0) {
				$result = DonationHandle::completeDonation($donationId);
				if ($result) {
					$response->assign('donationStatusMessage', 'innerHTML', 'Donation is complete.');
					$response->assign('donationStatusMessage', 'style.color', 'green');
					$response->assign('cancelDonationButton', 'style.display', 'none');
					$response->assign('completeDonationButton', 'style.display', 'none');
					$response->assign('newTransactionButton', 'style.display', 'none');
					$response->assign('editButton', 'disabled', 'disabled');
					$response->assign('notesSubmit', 'disabled', 'disabled');
					$response->assign('notesInput', 'disabled', 'disabled');
				}
				else {
					$response->assign('donationStatusMessage', 'innerHTML', 'Error in updating donation ticket.');
					$response->assign('donationStatusMessage', 'style.color', 'red');
				}
			}
			else {
				$response->assign('donationStatusMessage', 'innerHTML', 'No Donation ID and Agent ID. ERROR.');
				$response->assign('donationStatusMessage', 'style.color', 'red');
			}
			$response->call("parent.YAHOO.dms.complete_donation_dialog[$donationId].hide()");
			
			return$response;
		}
		
		function submitDonation($values) {
			$response = new xajaxResponse();
			$valuesArray = array();
			$agentId = isset($_SESSION['agentId']) ? $_SESSION['agentId'] : '0';
			$clientId = $_GET['client_id'];
			//$callId = $_GET['call_id'];
			$OK = false;
			$response->assign('donationStatusMessage', 'innerHTML', '');
			
			if ($agentId == 0) {
				$response->assign('donationStatusMessage', 'innerHTML', 'SESSION EXPIRED. PLEASE RE-LOGIN.');
			}
			else {
				# 1. do a check if there exist a donation for this client
					$result = DonationHandle::checkOpenDonation($clientId);
				
					if (isset($result['donation_status']) && $result['donation_status'] <= 2) {
						$response->assign('donationStatusMessage', 'innerHTML', 'Client has pending donation, cannot proceed.');
					}
					else {
						# 2. check if the mandatory fields are field up
							if ($values['pickupDate'] == '' || $values['amountPledged'] == '' || $values['donationMode'] == '' || $values['donationRecurrence'] == '') {
								$response->assign('donationStatusMessage', 'innerHTML', 'Please fill up the required (*) fields.');
							}
							else {
								# 3. check if the amount pledged entered is numeric
									if (!is_numeric(trim($values['amountPledged']))) {
										$response->assign('donationStatusMessage', 'innerHTML', 'Amount Pledged field input not integer.');
									}
									else {
										# 4. do a check if the amount pledged is in between the selected donation bracket
											/*
											$amountPledged = (int)trim($values['amountPledged']);
					
											switch($values['donationBracket']) {
												case "Young Builder\'s Circle":
													if ($amountPledged  <= 999 || $amountPledged >= 4999) {
														$response->assign('donationStatusMessage', 'innerHTML', 'Amount pledged and donation bracket does not match.');
													}else {$OK = true;}
												break;
												case "Br. H. Gabriel Connon FSC Fellows":
													if ($amountPledged  <= 4999 || $amountPledged >= 9999) {
														$response->assign('donationStatusMessage', 'innerHTML', 'Amount pledged and donation bracket does not match.');
													}else {$OK = true;}
												break;
												case "St. Miguel FSC Fellows":
													if ($amountPledged  <= 9999 || $amountPledged >= 24999) {
														$response->assign('donationStatusMessage', 'innerHTML', 'Amount pledged and donation bracket does not match.');
													}else {$OK = true;}
												break;
												case "St. Benilde FSC Fellows":
													if ($amountPledged  <= 24999 || $amountPledged >= 49999) {
														$response->assign('donationStatusMessage', 'innerHTML', 'Amount pledged and donation bracket does not match.');
													}else {$OK = true;}
												break;
												case "St. La Salle Fellows":
													if ($amountPledged  <= 49999 || $amountPledged >= 499999) {
														$response->assign('donationStatusMessage', 'innerHTML', 'Amount pledged and donation bracket does not match.');
													}else {$OK = true;}
												break;
												case "President\'s Fellows":
													if ($amountPledged  <= 499999) {
														$response->assign('donationStatusMessage', 'innerHTML', 'Amount pledged and donation bracket does not match.');
													}else {$OK = true;}
												break;
											}
											*/
									
										//if ($OK) {
											# check the date format
																				
													
											# set the current pickupdate to the first pickup date calculated
												$valuesArray['donation_currentpickupdate'] = $values['pickupDate']; // get the first entry, this will be the first scheduled pickupdate
											//$valuesArray['donation_bracket'] = $values['donationBracket'];
											$valuesArray['donation_amountpledged'] = abs($values['amountPledged']);
											$valuesArray['donation_preferredmodeofpayment'] = $values['donationMode'];
											$valuesArray['donation_recurrenceofpayment'] = $values['donationRecurrence'];
											$valuesArray['donation_notes'] = $values['donationNotes'];
											$valuesArray['donation_pickupdates'] = $values['pickupDate'];
											
											# 4. add to database
												$donationId = DonationHandle::addNewDonation($valuesArray, $agentId, $clientId);
												if ($donationId != '0' && is_numeric($donationId)) {
													$valuesArray2['call_tocalldate'] = $values['pickupDate'];
													$valuesArray2['call_tocalltime'] = mktime(9,0,0,0,0,0);

													$callId = DonationHandle::addPickupReminder($valuesArray2, $donationId, $agentId, $clientId); // this is to add the client in the call list for the pickup reminder 
												}
								
											if ($callId != 0 && is_numeric($callId)) {
												$response->assign('donationStatusMessage', 'innerHTML', 'Donation logged to database.');
												$response->assign('donationStatusMessage', 'style.color', 'green');
												$response->assign('closeButton', 'value', 'Close');
												$response->assign('doneButton', 'style.display', 'none');
									
												$response->assign('donationBracket','disabled','disabled');
												$response->assign('amountPledged','disabled','disabled');
												$response->assign('donationMode','disabled','disabled');
												$response->assign('donationRecurrence','disabled','disabled');
												$response->assign('donationDates','disabled','disabled');
												$response->assign('pickupDate','disabled','disabled');
												$response->assign('donationNotes','disabled','disabled');
											}
											else {
												$response->assign('donationStatusMessage', 'innerHTML', 'Donation Error.' . $callId);
											}
											
										//}
								}
							}
					}
	
			}
			$response->call("parent.YAHOO.dms.add_donation_dialog[$clientId].hide()");
			$response->call('parent.window.frames.dashboard_notification_area.location.reload()');
			$response->call("parent.refresh_client_window($clientId)");
			$response->call('parent.window.frames.dashboard_client_content.location.reload()');
			return$response;
		}
	
	# xajax process request 
		$xajax->processRequest();	
?>
<html>
<head>		       	
	
	<!-- fonts -->
			<link rel="stylesheet" type="text/css" href="../../lib/YUI/yui/build/fonts/fonts-min.css" />
	<!-- fonts -->
	
	<!-- DMS style sheet -->				
			<link rel="stylesheet" type="text/css" href="../../css/dms.css" />
	<!-- DMS style sheet -->	
		
	<!-- Xajax initialization code -->
		<script type="text/javascript" src="../../lib/XAJAX/xajax_js/xajax_core.js" />
		<?php $xajax->printJavaScript(); ?>
	<!-- Xajax initialization code -->	
	
</head>
<body class="yui-skin-sam">
<?php								
# process data #
	if (isset($_GET['donation_review']) && $_GET['donation_review'] == 1) {
		$window = 2;
	}
	elseif (isset($_GET['donation_id'])){
		$window = 1;
	}
	elseif (isset($_GET['client_id']) ) {
		$window = 0;
	}
	
	switch($window) {
		case 0: # display the new donation template
			echo"
				<div class='ticket_window'>					
					<form action='#' method='post' id='donationForm'>	
						<div id='donationStatusMessage' style='color:red; text-size:10px; text-align:center;'></div>
						<div class='font_title' style='background-color:#83b300; color:#fff;'>Donation Details:</div>
						<div class='font_small' style='padding-left:2px;'><span class='font_bold'>*1st Pickup Date:</span></div>
						<div class='font_small' style='padding-left:30px;'>
			";
?>
							<input type='text' name='pickupDate' id='pickupDate' /> <img src="../../images/b_calendar.png" onclick="<?=$dp->show('pickupDate')?>" />
<?php							
			echo "				
						</div>
						<div class='font_small' style='padding-left:2px;'><span class='font_bold'>*Amount Pledged: (no commas, ex. 1000)</span> </div>
						<div class='font_small' style='padding-left:30px;'><input type='text' id='amountPledged' name='amountPledged' style='width:150px;' />  </div>
						<div class='font_small' style='padding-left:2px;'><span class='font_bold'>*Donation Mode:</span> </div>
						<div class='font_small' style='padding-left:30px;'>
							<select id='donationMode' name='donationMode' style='width:150px;'>
								<option></option>
								<option value=\"Cash\">Cash</option>
								<option value=\"Check\">Check</option>
								<option value=\"Credit Card\">Credit Card</option>
								<option value=\"Wire Transfer\">Wire Transfer</option>
							</select> 
						</div>
						<div class='font_small' style='padding-left:2px;'><span class='font_bold'>*Recurrence of Payment:</span></div>
						<div class='font_small' style='padding-left:30px;'>
							<select id='donationRecurrence' name='donationRecurrence' style='width:150px;'>
								<option></option>
								<option value=\"One-time\">One-time</option>
								<option value=\"Monthly\">Monthly</option>
								<option value=\"Quarterly\">Quarterly</option>
								<option value=\"Semi-annually\">Semi-annually</option>
							</select> 
						</div>
						<div class='font_title' style='background-color:#83b300; color:#fff;'>Notes:</div>
						<div class='font_small' style='width:270px;'> <textarea id='donationNotes' name='donationNotes' style='width:265px; height:120px;'></textarea> </div>
						<input type='button' id='doneButton' value='Done' onClick=\"parent.show_add_donation_confirmation(" . $_GET['client_id'] . ")\" />
					</form>
				</div>
			";			
			//<input type='button' id='doneButton' value='Done' onClick=\"xajax_submitDonation(xajax.getFormValues('donationForm'))\" />
		break;
		case 1: # display the created donation
			
			# get the information from database
				$donationValues = DonationHandle::getDonation($_GET['donation_id']);
				
			# get client's total donation for this particular donation ID
				$totalDonation = DonationHandle::getTotalDonationValue($_GET['donation_id']);	
				
			if ($totalDonation >= $donationValues['donation_amountpledged']) {
				$result = DonationHandle::updateDonationItem ('donation_status', '4', $_GET['donation_id']);
				$totalDonation = number_format($totalDonation,2);
			}	
			
			# check the donation status is it is below '2'
				switch($donationValues['donation_status']) {
					case 0:
					case 1:
						$buttonHide = "";
						$donationStatus = '';
						$disabledInput = "";
					break;
					case 2:
						$buttonHide = "style='display:none;'";
						$donationStatus = "<span style='color:red;'>Donation Ticket is marked for deferral</span>";
						$disabledInput = "disabled='disabled'";
					break;
					case 3:
						$buttonHide = "style='display:none;'";
						$donationStatus = "<span style='color:red;'>Donation Ticket is deferred</span>";
						$disabledInput = "disabled='disabled'";
					break;
					case 4:
						$buttonHide = "style='display:none;'";
						$donationStatus = "<span style='color:green;'>Donation Complete</span>";
						$disabledInput = "disabled='disabled'";
					break;
				}
				
			# formatting of dates for display	
				$dateTime = $donationValues['donation_date'] . ' on ' . date('g:i A', $donationValues['donation_time']);
				//$pickupDates = explode(';', $donationValues['donation_pickupdates']);
			
			# get the donation ticket notes
				$notes = stripslashes($donationValues['donation_notes']);
				
			# get the last updated date of the donation ticket
				if ($donationValues['donation_updatetime'] != 0) {
					$lastUpdate = date('Y-m-d | g:i A',$donationValues['donation_updatetime']);
				}
				else {
					$lastUpdate = '-';
				}
				
				
			# get client's total donation for this particular donation ID
				$totalDonation = number_format(DonationHandle::getTotalDonationValue($_GET['donation_id']),2);
				
			# get all the transactions of this donation	
				$transactionList = TransactionHandle::getAllTransactions($_GET['donation_id']);
				
			echo"
				<div id='donationStatusMessage' style='color:red; text-size:10px; text-align:center;'>$donationStatus</div>
				<table width='100%' cellpadding='0' cellspacing='0' border='0' class='font_small'>
					<tr>
						<td width='115px'><span class='font_bold'>Donation ID: </span></td>
						<td width='150px'>".$_GET['donation_id']."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Last Updated: </span></td>
						<td>".$lastUpdate. "</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Amount Pledged: </span></td>
						<td>".number_format($donationValues['donation_amountpledged'],2)."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Mode of Payment: </span></td>
						<td>".$donationValues['donation_preferredmodeofpayment']."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Pickup Recurrence:</span></td>
						<td>".$donationValues['donation_recurrenceofpayment']."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Donation Date & Time: </span></td>
						<td>".$dateTime."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Current Pickup Date:</span></td>
						<td>".$donationValues['donation_currentpickupdate']." <input type='button' id='editButton' value='Edit' onclick=\"parent.open_reschedule_window(".$_GET['donation_id'].", ".$_GET['client_id'].", ".$_GET['call_id'].")\" $disabledInput /></td>
					</tr>
					<tr>
						<td><span class='font_bold'>Transactions Made:</span></td>
						<td><select>
			";
				
				foreach ($transactionList as $transactions) {
					echo "<option onclick='parent.open_transaction_window(".$transactions['transaction_id'].")'> @". $transactions['transaction_date'] ." (".$transactions['transaction_id'].") </option>"; 
				}

			echo "
				</select></td>
					</tr>
					<tr>
						<td><span class='font_bold'>Amount Donated: </span></td>
						<td>".$totalDonation."</td>
					</tr>
				</table>
			";
			
			echo"
				<div class='font_small' style='padding-left:2px;'><span class='font_bold'>Donation Notes:</span></div>
				<div class='font_small' style='padding-left:2px;'><span class='font_bold'><textarea style='width:280px;height:100px;' scrolling='auto' disabled='disabled'>$notes</textarea></span></div>
				<form method='post' action='#' name='notesForm' id='notesForm'>
					<div class='font_small' style='padding-left:2px;'><span class='font_bold'><textarea style='width:280px;height:100px;' scrolling='auto' name='notesInput' id='notesInput' $disabledInput></textarea></span></div>
					<input type='button' name='notesSubmit' id='notesSubmit' value='Update Notes' onclick=\"xajax_updateNotes(xajax.getFormValues('notesForm'))\" $disabledInput />
				</form>
				<input type='button' value='New Ticket' onClick='parent.open_newticket_window(".$_GET['call_id'].",".$_GET['client_id'].")' />
				<input type='button' name='newTransactionButton' id='newTransactionButton' value='New Transaction' onClick='parent.open_newtransaction_window(".$_GET['donation_id'].", ".$_GET['client_id'].")' $buttonHide />
				<input type='button' value='Profile' onClick='parent.open_client_window(".$_GET['call_id'].",".$_GET['client_id'].")' />
				<input type='button' name='cancelDonationButton' id='cancelDonationButton' value='Cancel Donation' onclick='parent.show_cancel_donation_confirmation(".$_GET['donation_id'].")' $buttonHide />
			";
			
			if (isset($_SESSION['agentPermissions']) && $_SESSION['agentPermissions'] == 1) {
				if ($donationValues['donation_status'] == 1) {
					echo "
						<input type='button' id='completeDonationButton' name='completeDonationButton' onclick='parent.show_complete_donation_confirmation(".$donationValues['donation_id'].")' value='Complete Donation'/>
					";
				}
			}
			
		break;
		case 2: # display donation ticket for review
			
			# get the information from database
				$donationValues = DonationHandle::getDonation($_GET['donation_id']);
				
			# get client's total donation for this particular donation ID
				$totalDonation = number_format(DonationHandle::getTotalDonationValue($_GET['donation_id']),2);	
				
			if ($totalDonation >= $donationValues['donation_amountpledged']) {
				$result = DonationHandle::updateDonationItem ('donation_status', '4', donationId);
			}	
				
			# check the donation status is it is below '2'
				switch($donationValues['donation_status']) {
					case 0:
					case 1:
						$buttonHide = "";
						$donationStatus = '';
						$disabledInput = "";
					break;
					case 2:
						$buttonHide = "style='display:none;'";
						$donationStatus = "<span style='color:red;'>Donation Ticket is marked for deferral</span>";
						$disabledInput = "disabled='disabled'";
					break;
					case 3:
						$buttonHide = "style='display:none;'";
						$donationStatus = "<span style='color:red;'>Donation Ticket is deferred</span>";
						$disabledInput = "disabled='disabled'";
					break;
					case 4:
						$buttonHide = "style='display:none;'";
						$donationStatus = "<span style='color:green;'>Donation Complete</span>";
						$disabledInput = "disabled='disabled'";
					break;
				}
				
			# formatting of dates for display	
				$dateTime = $donationValues['donation_date'] . ' on ' . date('g:i A', $donationValues['donation_time']);
				//$pickupDates = explode(';', $donationValues['donation_pickupdates']);
			
			# get the donation ticket notes
				$notes = stripslashes($donationValues['donation_notes']);
				
			# get the last updated date of the donation ticket
				if ($donationValues['donation_updatetime'] != 0) {
					$lastUpdate = date('Y-m-d | g:i A',$donationValues['donation_updatetime']);
				}
				else {
					$lastUpdate = '-';
				}
				
			# get all the transactions of this donation	
				$transactionList = TransactionHandle::getAllTransactions($_GET['donation_id']);
				
			echo"
				<div id='donationStatusMessage' style='text-size:10px; text-align:center;'>$donationStatus</div>
				<table width='100%' cellpadding='0' cellspacing='0' border='0' class='font_small'>
					<tr>
						<td width='115px'><span class='font_bold'>Donation ID: </span></td>
						<td width='150px'>".$_GET['donation_id']."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Last Updated: </span></td>
						<td>".$lastUpdate. "</td>
					</tr>
					<!--<tr>
						<td><span class='font_bold'>Donation Category: </span></td>
						<td>".$donationValues['donation_bracket']."</td>
					</tr>-->
					<tr>
						<td><span class='font_bold'>Amount Pledged: </span></td>
						<td>".number_format($donationValues['donation_amountpledged'],2)."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Mode of Payment: </span></td>
						<td>".$donationValues['donation_preferredmodeofpayment']."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Pickup Recurrence:</span></td>
						<td>".$donationValues['donation_recurrenceofpayment']."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Donation Date & Time: </span></td>
						<td>".$dateTime."</td>
					</tr>
					<tr>
						<td><span class='font_bold'>Current Pickup Date:</span></td>
						<td>".$donationValues['donation_currentpickupdate']." <input type='button' id='editButton' value='Edit' onclick=\"parent.open_reschedule_window(".$_GET['donation_id'].", ".$_GET['client_id'].", '-')\" $disabledInput /></td>
					</tr>
					<!--<tr>
						<td><span class='font_bold'>Current Pickup Date:</span></td>
						<td>".$donationValues['donation_currentpickupdate']."</td>
					</tr>-->
					<tr>
						<td><span class='font_bold'>Transactions Made:</span></td>
						<td><select>
			";
				
				foreach ($transactionList as $transactions) {
					echo "<option onclick='parent.open_transaction_window(".$transactions['transaction_id'].")'> Transaction ID# ".$transactions['transaction_id']." </option>"; 
				}

			echo "
				</select></td>
					</tr>
					<tr>
						<td><span class='font_bold'>Amount Donated: </span></td>
						<td>".$totalDonation."</td>
					</tr>
				</table>
			";
			
			echo "
				<div class='font_small' style='padding-left:2px;'><span class='font_bold'>Donation Notes:</span></div>
				<div class='font_small' style='padding-left:2px;'><span class='font_bold'><textarea style='width:280px;height:100px;' scrolling='auto' disabled='disabled'>$notes</textarea></span></div>
				<input type='button' onclick='parent.YAHOO.dms.dashboard_donation_windows[".$_GET['donation_id']."].hide()' value='Close'/>
				<input type='button' value='Profile' onClick='parent.open_profile_window(".$donationValues['client_id'].")' />
			";
			
			if (isset($_SESSION['agentPermissions']) && $_SESSION['agentPermissions'] == 1) {
				if ($donationValues['donation_status'] == 1) {
					echo "
						<input type='button' id='completeDonationButton' name='completeDonationButton' onclick='parent.show_complete_donation_confirmation(".$donationValues['donation_id'].")' value='Complete Donation'/>
					";
				}
			}
			
		break;
	}
?>
 					
	
</body>
</html>
